package com.letoken.platform.app.controller;

import com.letoken.platform.app.service.AppSettingsService;
import com.letoken.platform.pub.annotation.auth.NotAuthorization;
import com.letoken.platform.pub.res.ApiResponse;
import com.letoken.platform.repo.app.res.settings.QueryAppNodeAddressListRes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wyl
 * @date 2023/2/1 18:17
 * @Version 1.0
 */
@RestController
@RequestMapping("/settings")
@Api(tags = "我的-系统设置")
public class AppSettingsController {

    @Autowired
    private AppSettingsService appSettingsService;

    @NotAuthorization
    @GetMapping("/chainNode/address")
    @ApiOperation(value = "根据网络类型查询节点地址", notes = "根据网络类型查询节点地址")
    public ApiResponse<List<QueryAppNodeAddressListRes>> chainNodeAddressList(@ApiParam(value = "网络类型(1主网 2测试网)", example = "1") @RequestParam Integer type) {
        if(!type.equals("1") && type.equals("2")) {
            return ApiResponse.create(null);
        }
        return ApiResponse.create(appSettingsService.chainNodeAddressList(type));
    }
}
